﻿#pragma once

#include "command.h"

namespace CAGD
{

/**
 * Lagrange 插值曲线.
 */
class CmdLagrange : public CmdCurvePainter
{
  public:
    CAGD_CREATE_COMMAND(CmdLagrange)

    /**
     * @brief 构造曲线.
     * @return
     * @see
     */
    CmdStatus Perform() override;
};

/**
 * Bezier 动力学生成.
 */
class CmdBezierDyn : public CmdCurvePainter
{
  public:
    CAGD_CREATE_COMMAND(CmdBezierDyn)

    /**
     * @brief 构造曲线.
     * @return
     * @see
     */
    CmdStatus Perform() override;
};

/**
 * 构造 Bezier 曲线.
 */
class CmdBezier : public CmdCurveBuilder
{
  public:
    CAGD_CREATE_COMMAND(CmdBezier)

    /**
     * @brief 构造曲线.
     * @return
     * @see
     */
    CmdStatus Perform() override;
};

/**
 * 拟合 Bezier 曲线.
 */
class CmdBezierFit : public CmdCurveBuilder
{
  public:
    CAGD_CREATE_COMMAND(CmdBezierFit)

    /**
     * @brief 构造曲线.
     * @return
     * @see
     */
    CmdStatus Perform() override;
};

/**
 * 3 次 B 样条曲线.
 */
class CmdBSpline : public CmdCurveBuilder
{
  public:
    CAGD_CREATE_COMMAND(CmdBSpline)

    /**
     * @brief 构造曲线.
     * @return
     * @see
     */
    CmdStatus Perform() override;
};

/**
 * 拟合 B 样条曲线.
 */
class CmdBSplineFit : public CmdCurveBuilder
{
  public:
    CAGD_CREATE_COMMAND(CmdBSplineFit)

    /**
     * @brief 构造曲线.
     * @return
     * @see
     */
    CmdStatus Perform() override;
};

/**
 * 3 次 B 样条插值曲线.
 */
class CmdBSplineIntp : public CmdCurveBuilder
{
  public:
    CAGD_CREATE_COMMAND(CmdBSplineIntp)

    /**
     * @brief 构造曲线.
     * @return
     * @see
     */
    CmdStatus Perform() override;
};

/**
 * 均匀 B 样条 Lane-Riesenfeld 算法.
 */
class CmdBSplineLane : public CmdCurvePainter
{
  public:
    CAGD_CREATE_COMMAND(CmdBSplineLane)

    /**
     * @brief 构造曲线.
     * @return
     * @see
     */
    CmdStatus Perform() override;
};

/**
 * B 样条细分算法.
 */
class CmdBSplineDivide : public CmdCurvePainter
{
  public:
    CAGD_CREATE_COMMAND(CmdBSplineDivide)

    /**
     * @brief 构造曲线.
     * @return
     * @see
     */
    CmdStatus Perform() override;

  protected:
    /**
     * @brief 奇偶点列细分，获得对应的索引.
     * @param even 奇偶性
     * @param points 初始点
     * @param record 记录细分点
     * @param index 点对应的索引
     * @param S 双尺度系数
     * @see
     */
    void Subdivide(int even, std::vector<BPnt> &points, std::vector<BPnt> &record, std::vector<int> &index,
                   std::vector<double> &S);
};

} // namespace CAGD
